'''
一种事物可以体现为多种形态
'''
class Shape:
    def __init__(self,type):
        self.type = type
    def area(self):
        return 0

class Circle(Shape):
    def __init__(self,type1,r):
        super().__init__(type1)
        self.r = r

    # 方法重写
    def area(self):
        return 3.14*self.r**2

class Square(Shape):
    def __init__(self,type1,b):
        super().__init__(type1)
        self.b = b

    def area(self):
        return self.b**2

def method(shape:Shape): # int str list  shape1代表一个对象
    print(shape.type,"面积为:",shape.area())

s = Shape("形状")
c = Circle("圆",5)
q = Square("正方形",6)

method(s)
method(c)
method(q)

class X:
    def __init__(self,type):
        self.type = type

    def area(self):
        return 56

method(X("未知类型"))
# java是强类型的语言，python是弱类型的语言